<script>
  import { share } from '@/server/api/config/share.js';
  import * as memberPoints from '@/utils/memberPoints/index.js';
  import * as Utils from '@/utils/index.js';

  export default {
    onLaunch: async function (e) {
      console.log('App Launch');
      try {
        if (e.query.wxlsToken) {
          uni.setStorageSync('wxlsToken', e.query.wxlsToken);
          this.$store.commit('setToken', e.query.wxlsToken);
        }
      } catch (e) {}
      uni.hideTabBar();
      try {
        const { data: res } = await share(
          process.env.NODE_ENV === 'development' ? 277 : 277, // TODO
        );
        if (res.data.banner) {
          res.data.banner = res.data.banner.split(',');
        }
        res.data.configJson = JSON.parse(res.data.configJson);
        this.$store.dispatch('getConfig', res.data);
      } catch (e) {}
      if (this.isWxH5()) return;

      this.$isResolve();

      memberPoints.main(this.$store.getters.config.code); // 埋点访问量
    },
    onShow: function () {
      console.log('App Show');
    },
    onHide: function () {
      console.log('App Hide');
    },
    methods: {
      isWxH5() {
        let iswx = false;
        let ua = navigator.userAgent.toLowerCase();
        if (/micromessenger/.test(ua) && !window.location.hash.includes('pages/index/detail')) {
          window.location.href = this.$store.getters.config.jumpAddress;
          iswx = true;
        }
        return iswx;
      },
    },
  };
</script>

<style lang="scss">
  @import url('@/static/icon/iconfont.css');
  @import url('/static/fonts/iconfont.css');
  @import './tuniao-ui/index.scss';
  @import './tuniao-ui/iconfont.css';
  /*每个页面公共css */
  * {
    box-sizing: border-box;
  }
  page,
  body {
    -webkit-user-select: text; /* Safari */
    -ms-user-select: text; /* IE 10+ and Edge */
    user-select: text; /* Standard syntax */
  }
  body {
    min-width: 320px;
    max-width: 750px;
    width: 10rem;
    margin: 0 auto;
  }
  @media screen and (min-width: 750px) {
    html {
      font-size: 75px !important;
    }
  }
  ul {
    padding: 0;
  }
  ul li {
    list-style-type: none;
  }
  image,
  img {
    font-size: 0;
  }
  .no-image-bg {
    background-color: #eee;
  }
  /* 过长显示省略号 */
  .text-long-ellipsis {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }
  .filter-grayscale {
    filter: grayscale(90%);
    -webkit-filter: grayscale(90%);
    -moz-filter: grayscale(90%);
    -ms-filter: grayscale(90%);
    -o-filter: grayscale(90%);
  }
  .filter-grayscale-40 {
    filter: grayscale(40%);
    -webkit-filter: grayscale(40%);
    -moz-filter: grayscale(40%);
    -ms-filter: grayscale(40%);
    -o-filter: grayscale(40%);
  }
  .w-100 {
    width: 100%;
  }
  .h-100 {
    height: 100%;
  }
  .flex {
    display: flex !important;
  }
  .flex-1 {
    flex: 1;
  }
  .items-center {
    align-items: center !important;
  }
  .justify-center {
    justify-content: center !important;
  }
  .justify-between {
    justify-content: space-between !important;
  }
  .justify-around {
    justify-content: space-around !important;
  }
  .justify-start {
    justify-content: flex-start !important;
  }
  .justify-end {
    justify-content: flex-end !important;
  }
  .flex-direction-column {
    flex-direction: column;
  }
  .flex-wrap {
    flex-wrap: wrap;
  }
  .text-center {
    text-align: center;
  }
  .box-shadow {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 6px rgba(0, 0, 0, 0.04);
  }

  .buttonAnimate {
    animation-name: ball;
    animation-duration: 2s;
    animation-iteration-count: infinite;
    animation-timing-function: linear;
  }
  @keyframes ball {
    0% {
      transform: scale(1.05);
    }

    25% {
      transform: scale(1);
    }

    50% {
      transform: scale(0.95);
    }

    75% {
      transform: scale(1);
    }

    100% {
      transform: scale(1.05);
    }
  }
</style>
